<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Admissions extends CI_Controller {

	/**
	 * Index Page for this controller.
	 *
	 * Maps to the following URL
	 * 		http://example.com/index.php/welcome
	 *	- or -  
	 * 		http://example.com/index.php/welcome/index
	 *	- or -
	 * Since this controller is set as the default controller in 
	 * config/routes.php, it's displayed at http://example.com/
	 *
	 * So any other public methods not prefixed with an underscore will
	 * map to /index.php/welcome/<method_name>
	 * @see http://codeigniter.com/user_guide/general/urls.html
	 */
	 
	var $c_name = '招生就业';
	
	public function index()
	{
		$news[0] = array('type'=>'硕士招生', 'news'=>$this->Recruitnews->get_last_n_entries("硕士招生"));
		$news[1] = array('type'=>'硕士生复试', 'news'=>$this->Recruitnews->get_last_n_entries("硕士生复试"));
		$data['news'] = $news;
		$data['page_title'] = $this->c_name;
		$data['base'] = 'admissions';
		$this->load->view('header', $data);
		$this->load->view('sidebar');
		$this->load->view('index');
		$this->load->view('footer');
	}
	
	public function page($off_set=0, $type="硕士招生")
	{		
		$type = urldecode($type);
		$per_page = $this->config->item('per_page');
		//echo $off_set;
		$news = $this->Recruitnews->get_entries($per_page, $off_set, $type);
		
		$pagination['base_url'] = site_url('admissions/page/');
		$pagination['post_url'] = '/'.$type;
		#$pagination['base_url'] = site_url('news/page/');
		$pagination['total_rows'] = $this->Recruitnews->get_total_num($type);
		$pagination['per_page'] = $per_page; 
		
		$data['news'] = $news;
		$data['type'] = $type;
		$data['page_title'] = urldecode($type);
		$data['pagination'] = $pagination;
		$data['up_cate'] = $this->c_name;
		$data['base'] = 'admissions';
		
		$this->load->view('header', $data);	
		$this->load->view('sidebar');		
		$this->load->view('newslist');
		$this->load->view('footer');
	}
	
	public function item($id) {
		$ee = $this->Recruitnews->get_entrie($id);
		if (count($ee) > 0) {
			$data['news'] = $ee[0];
		} else {
			$data['page_title'] = 'Not found';
			$this->load->view('header', $data);	
			$this->load->view('contact');
			$this->load->view('sidebar');
			$this->load->view('footer');
			return;
		}
		
		$data['page_title'] = $data['news']->Title;
		$data['up_cate'] = $this->c_name;
		
		$data['appendix'] = $this->News->get_all_atts($data['news']->NewsId, $data['news']->Type);
		
		$this->load->view('header', $data);	
		$this->load->view('sidebar');		
		$this->load->view('single');
		$this->load->view('footer');
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */